package com.stony.mapper;

import com.stony.model.HostModel;
import org.springframework.jdbc.core.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Created by ShiHui on 2014/6/3.
 */
public class HostMapper implements RowMapper<HostModel> {

    @Override
    public HostModel mapRow(ResultSet rs, int rowNum) throws SQLException {
        HostModel host = new HostModel();
        host.setId(rs.getInt("id"));
        host.setHost(rs.getString("host"));
        host.setPort(rs.getInt("port"));
        host.setType(rs.getString("type"));
        host.setCluster(rs.getString("cluster"));
        host.setShard(rs.getString("shard"));
        host.setReplSet(rs.getString("repl_set"));
        host.setLastPing(rs.getTimestamp("last_ping"));
        host.setUpSince(rs.getTimestamp("up_since"));
        host.setVersion(rs.getString("version"));
        return host;
    }
}
